﻿using System;
using System.Collections;
using System.Windows.Forms;

namespace DomExplorer
{
    static class ElementAccess
    {

        public static Hashtable GetElementInfo(HtmlElement theElement)
        {
            var items = new Hashtable();

            foreach (string item in Properties.Settings.Default.AttribArray)
            {
                String val = theElement.GetAttribute(item);

                if (val != null && val.Length > 0)
                {
                    items.Add(item, theElement.GetAttribute(item));

                }
            }

            return items;
        }


        /// <summary>
        /// Gets general information about the loaded webpage and adds elements to the listview
        /// </summary>
        public static Hashtable ProcessPageInfo(HtmlDocument theDoc)
        {
            Hashtable props = new Hashtable();


            props.Add("Title:", theDoc.Title);
            props.Add("Host:", theDoc.Url.Host);
            props.Add("Port:", theDoc.Url.Port.ToString());
            props.Add("Encoding:", theDoc.Encoding);
            props.Add("Frames:", theDoc.Window.Frames.Count.ToString());
            props.Add("Images:", theDoc.Images.Count.ToString());
            props.Add("Links:", theDoc.Links.Count.ToString());

            return props;

        }




    }
}
